<!-- template inhertance -->
<extend name="layout/layui24"/>

<!-- styles -->
<block name="linkcss">

</block>

<!-- scripts -->
<block name="linkjs">

</block>

<!-- page title -->
<block name="webtitle">
    <title>授权</title>
</block>

<!-- navagations -->
<block name="breadcrumb">
    <ol class="breadcrumb breadcrumb-edit">
        <li><a href="index">个人中心</a></li>
        <li class="active">授权</li>
    </ol>
</block>

<!-- main body -->
<block name="content">
    <div class="mb-20">
        <a href="authorizationCreate" class="layui-btn layui-btn-primary">
            <i class="icon-plus"></i>
            创建授权
        </a>
    </div>

    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li lay-id="from_me" class="layui-this">我创建的授权</li>
            <li lay-id="to_me">交给我的授权</li>
        </ul>
        <div class="layui-tab-content">
            <!--我创建的授权-->
            <div class="layui-tab-item layui-show">
                <notempty name="from_me">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>编号</th><!--自动生成编号区分每一条授权-->
                            <th>状态</th>
                            <th>授权模块</th>
                            <th>创建人</th>
                            <th>被授权人</th>
                            <th>授权开始时间</th>
                            <th>授权结束时间</th>
                            <th>创建时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="from_me" id="vo">
                            <tr>
                                <td>
                                    <a href="authorizationShow">{$vo.number}</a>
                                </td>
                                <td>
                                    {//区分状态，若为0表示已启用、1表示已禁用、-1表示未启用}
                                    <switch name="vo.status">
                                        <case value="0">
                                            <span class="tag tag-success">已启用</span>
                                        </case>
                                        <case value="1">
                                            <span class="tag tag-danger">已禁用</span>
                                        </case>
                                        <case value="-1">
                                            <span class="tag tag-warning">未启用</span>
                                        </case>
                                        <default/>
                                        <span class="tag tag-night">已过期</span>
                                    </switch>
                                </td>
                                <td>{$vo.module}</td>
                                <td>{$vo.user}</td>
                                <td>{$vo.auth_user}</td>
                                <td>{$vo.from|date='Y-m-d',###}</td>
                                <td>{$vo.to|date='Y-m-d',###}</td>
                                <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                    <!-- 分页 -->
                    <ul class="pagination pagination-edit">{$page}</ul>
                    {//如果没有创建的授权的记录则显示如下图标}
                    <else/>
                    <div class="no--info"></div>
                </notempty>
            </div>

            <!--交给我的授权-->
            <div class="layui-tab-item">
                <notempty name="to_me">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>编号</th><!--自动生成编号区分每一条授权-->
                            <th>状态</th>
                            <th>授权模块</th>
                            <th>创建人</th>
                            <th>被授权人</th>
                            <th>授权开始时间</th>
                            <th>授权结束时间</th>
                            <th>创建时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="to_me" id="vo">
                            <tr>
                                <td>
                                    <a href="authorizationShow">{$vo.number}</a>
                                </td>
                                <td>
                                    {//区分状态，若为0表示已启用、1表示已禁用、-1表示未启用、其他表示已过期}
                                    <switch name="vo.status">
                                        <case value="0">
                                            <span class="tag tag-success">已启用</span>
                                        </case>
                                        <case value="1">
                                            <span class="tag tag-danger">已禁用</span>
                                        </case>
                                        <case value="-1">
                                            <span class="tag tag-warning">未启用</span>
                                        </case>
                                        <default/>
                                        <span class="tag tag-night">已过期</span>
                                    </switch>
                                </td>
                                <td>{$vo.module}</td>
                                <td>{$vo.user}</td>
                                <td>{$vo.auth_user}</td>
                                <td>{$vo.from|date='Y-m-d',###}</td>
                                <td>{$vo.to|date='Y-m-d',###}</td>
                                <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                    <!-- 分页 -->
                    <ul class="pagination pagination-edit">{$page}</ul>
                    {//如果没有交给我的授权的记录则显示如下图标}
                    <else/>
                    <div class="no--info"></div>
                </notempty>
            </div>
        </div>
    </div>

</block>

<block name="scripts">
    <script>
        $(function () {
            layui.use(['element'],function () {
                var element = layui.element;

                //获取hash来切换选项卡
                var layId = location.hash.replace(/^#tab=/,'');
                element.tabChange('tab',layId);

                //监听tab切换，改变hash值
                element.on('tab(tab)',function () {
                    location.hash = 'tab=' + this.getAttribute('lay-id');
                })
            })
        })
    </script>
</block>